#include <iostream>
using namespace std;

typedef struct intNode
{
    int data;
    intNode *next;
} intNode;

typedef struct intLinkStack
{
    intNode *bottom;
    intNode *top;
} ILS;

bool push(ILS *stack, int n)
{
    intNode *newNode = new intNode();
    newNode->data = n;
    if (stack->bottom == NULL)
    {
        stack->bottom = newNode;
        stack->top = newNode;
    }
    newNode->next = stack->top;
    stack->top = newNode;
    return true;
}

int pop(ILS *stack)
{
    if (stack->bottom == NULL)
        return -1;
    int res = stack->top->data;

    if (stack->bottom == stack->top) // 唯一元素
    {
        stack->bottom = NULL;
        stack->top = NULL;
    }
    else // 非唯一元素
    {
        stack->top = stack->top->next;
    }
    return res;
}

int top(ILS *stack)
{
    if (stack->bottom == NULL)
        return -1;
    return stack->top->data;
}
ILS *init()
{
    ILS *stack = new ILS();
    push(stack, 2);
    push(stack, 2);
    push(stack, 2);
    push(stack, 2);
    return stack;
}
int main(int argc, char const *argv[])
{
    ILS *s = init();
    printf("%d,%d", pop(s), top(s));
    return 0;
}
